-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加慢SQL的的优化管理功能 #2549
base: master
Are you sure you want to change the base?
添加慢SQL的的优化管理功能 #2549
Conversation
这个test怎么一直失败呢,我先去掉了 |
你写错了, |
本地可以跑的 https://github.com/hhyo/Archery/wiki/development#%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95 看一下这里的, 简单配置一下就行 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2549 +/- ##
==========================================
- Coverage 76.82% 76.74% -0.08%
==========================================
Files 117 117
Lines 16073 16115 +42
==========================================
+ Hits 12348 12368 +20
- Misses 3725 3747 +22 ☔ View full report in Codecov by Sentry. |
) | ||
.values( | ||
"SQLText", | ||
"SQLId", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个PR中,SQLId, checksum, SQLChecksum实际上都是archery.mysql_slow_query_review表的checksum字段。是为了显示方便所以有不同叫法。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review_checksum也是
@permission_required("sql.menu_slowquery", raise_exception=True) | ||
def listreview(request): | ||
"""获取优化详情""" | ||
checksum = request.POST.get("review_checksum") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
获取用户在页面中勾选的SQL语句对应的checksum
@@ -251,3 +264,45 @@ def report(request): | |||
|
|||
result = {"status": 0, "msg": "", "data": line.render_embed()} | |||
return HttpResponse(json.dumps(result), content_type="application/json") | |||
|
|||
|
|||
@permission_required("sql.menu_slowquery", raise_exception=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
沿用查看慢日志的权限,没有单独加权限控制,后续可以添加。
@permission_required("sql.menu_slowquery", raise_exception=True) | ||
def editreview(request): | ||
"""更新优化详情""" | ||
checksum = request.POST.get("checksum") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
获取欲操作的SQL语句对应的checksum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
编辑框传过来的值
reviewed_on = reviewed_on, | ||
comments = comments, | ||
reviewed_status = reviewed_status | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
更新数据库
@LeoQuote 大佬方便的话麻烦加一下单元测试。另外,我看black给我改写的不能用,有些逻辑变了 |
能否考虑使用 rest_framework 实现? 我看你这个主要逻辑还是有点restful 风格的,black 必须能过哈,他给你修的不行你就自己修 |
那估计要研究很久了,还是初学者哈哈 |
ImportError while loading conftest '/home/runner/work/Archery/Archery/conftest.py'. |
更新了wiki, 得装一批开发用的依赖 |
我觉得这个功能不错,期待中 |
这个功能来自之前的一个想法:#2382
演示demo
另外,关于“编辑详情”页面的“状态”:
我的设想是,
open:开始认领这个慢SQL
resolved:已有解决方案
pending:难以优化,暂挂
closed:这个SQL的优化方案已经在业务层面实施完毕